from django.shortcuts import render
from rest_framework.views import APIView
from rest_framework.response import Response
from .seriver import get_enable_coupons
from department.models import Department
# Create your views here.



class CouponView(APIView):
    def post(self,request):
        user_id = request.data.get('user_id')
        department = request.data.get('department')
        department = Department.objects.filter(name=department).first().id
        amount = int(request.data.get('amount'))
        coupons = get_enable_coupons(user_id, department, amount)
        return Response({'coupons': coupons})






